/**
 * ������ݿ�
 */
/**
 * @author wilson
 *
 */
package com.db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.vo.Book;

public class Db{
	String url3 = "jdbc:mysql://101.201.235.217:3306/book?characterEncoding=utf-8";  

	String url = "jdbc:mysql://127.0.0.1:3306/book?characterEncoding=utf-8";  
	String url2 = "jdbc:oracle:thin:@localhost:1521:orcl";  

	private Connection conn=null;
	public Connection getConnect() throws ClassNotFoundException,SQLException{
		try{
			Class.forName("com.mysql.jdbc.Driver").newInstance();//������ݿ���
		}catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		conn =DriverManager.getConnection(url3,"root","mysqlpasswd");//��֤��ݿ�
		return conn;
	}
	
//	public Connection getConnect2() throws ClassNotFoundException,SQLException{
//		try{
//			Class.forName("oracle.jdbc.OracleDriver").newInstance();//������ݿ���
//		}catch (InstantiationException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		} catch (IllegalAccessException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		conn =DriverManager.getConnection(url,"scott","123456");//��֤��ݿ�
//		return conn;
//	}
//	
//	
//	public static void main(String[] args) throws ClassNotFoundException, SQLException {
//		Db db=new Db();
//		if(db.getConnect()!=null){
//			System.out.println("scus");
//		}
//	}
//	private String url="jdbc:sqlserver://localhost:1433;datebaseName=myFirstDataBase";
//	private Connection conn=null;
//	
//	public Connection getConnect() throws ClassNotFoundException,SQLException{
//		try{
//			Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();//������ݿ���
//		}catch (InstantiationException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		} catch (IllegalAccessException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		conn =DriverManager.getConnection(url,"yzy","8880610");//��֤��ݿ�
//		return conn;
//	}
//	public static void main(String[] args) throws ClassNotFoundException, SQLException{
//		String url="jdbc:sqlserver://localhost:1433;datebaseName=myFirstDataBase";
//		Connection conn=null;
//		
//		try{
//			Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();//������ݿ���
//		}catch (InstantiationException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		} catch (IllegalAccessException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		conn =DriverManager.getConnection(url,"yzy","8880610");//��֤��ݿ�
//		if(conn!=null){
//			System.out.println( "hello world");
//		}
//		else{
//			System.out.println( "failed");
//		}
//		String sql = "use myFirstDataBase select * from StuInfo ";
//	    Statement sta = conn.createStatement();
//	    ResultSet rs = sta.executeQuery(sql);
//	    while(rs.next()) {
//           
//            System.out.println(rs.getInt(1));
//    
//        }
//	       
//	            Vo vo = new Vo();
////	            String username = rs.getString("username"); 
//	            System.out.println( "hello world");
//	            System.out.println( rs.getString("username"));
//	        } 
//	}
}